<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateStatDailyKeepTable extends Migration
{
    protected $connection = 'stat';

    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('stat_daily_keep', function (Blueprint $table) {
            $table->increments('id');
            $table->date('dt')->comment('统计日期');
            $table->tinyInteger('stat_type')->default(-1)->comment('统计人群类型');
            $table->double('keep_1', 5, 2)->default(0)->comment('次日留存');
            $table->double('keep_2', 5, 2)->default(0)->comment('2日留存');
            $table->double('keep_3', 5, 2)->default(0)->comment('3日留存');
            $table->double('keep_7', 5, 2)->default(0)->comment('7日留存');
            $table->double('keep_15', 5, 2)->default(0)->comment('15日留存');
            $table->double('keep_30', 5, 2)->default(0)->comment('30日留存');
            $table->timestamps();
            $table->tinyInteger('flag')->default(1)->comment('记录状态');
            $table->index('dt', 'dt');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('stat_daily_keep');
    }
}
